1. Field
This disclosure generally relates to caching data and in particular to writing data received over a network to a cache.
2. Background
A client application may request data over a network and write the data to a local cache. In an example, the client application may stream data over a high-speed network connection and display the data to a user. Writing data to a cache may enable the client application to quickly retrieve the data from the local cache rather than download the data again over the network. Further, the user may access and use the client application even when the high-speed network connection is unavailable or impractical because the client application may retrieve the data from the cache rather than over the network.
The data may be inserted into the cache, and the older data in the cache may be removed after a maximum amount of data has been stored in the cache to make room for new data. Deleting the old data may leave holes in the cache, and it may be desirable to compact the cache. Cache compaction, however, may be time consuming and cause glitches in the application. For example, the application may not have access to the cache while it is being compacted. Accordingly, the user may experience a time delay when waiting for the application to respond. This may degrade the user's experience.